import 'package:flutter/material.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/widget/button_widget.dart';

class ConfirmationDialog extends StatelessWidget {
  final String title; // 弹窗标题
  final String message; // 弹窗内容
  final String confirmButtonText; // 确认按钮文字
  final String cancelButtonText; // 取消按钮文字
  final VoidCallback onConfirm; // 确认按钮回调
  final VoidCallback onCancel; // 取消按钮回调

  const ConfirmationDialog({
    super.key,
    required this.title,
    required this.message,
    this.confirmButtonText = '确认',
    this.cancelButtonText = '取消',
    required this.onConfirm,
    required this.onCancel,
  });

  @override
  Widget build(BuildContext context) {
    return Dialog(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(20), // 圆角
      ),
      elevation: 10, // 阴影
      backgroundColor: const Color.fromRGBO(34, 39, 49, 1), // 背景颜色
      child: Container(
        padding: const EdgeInsets.all(20),
        child: Column(
          mainAxisSize: MainAxisSize.min, // 使高度自适应内容
          children: [
            // 标题
            Text(
              title,
              style: const TextStyle(
                fontSize: 20,
                fontWeight: FontWeight.bold,
                color: AppColors.fontColor,
              ),
            ),
            title == ''
                ? const SizedBox(height: 0)
                : const SizedBox(height: 16), // 间距
            // 内容
            Text(
              message,
              style: const TextStyle(fontSize: 16, color: AppColors.fontColor),
            ),
            const SizedBox(height: 24), // 间距
            // 按钮
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                ButtonWidget(
                  label: '取消',
                  fontColor: AppColors.fontColor,
                  width: 128,
                  backgroundColor: const Color.fromRGBO(255, 255, 255, 0.1),
                  onPressed: () {
                    onCancel();
                  },
                ),
                ButtonWidget(
                  label: '确认',
                  width: 128,
                  onPressed: () {
                    onConfirm();
                  },
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
